#include <iostream>
#include "person.pb.h"
using namespace std;

char arr[1024]={0};
int len;

void set_person()
{
    Person obj;
    obj.set_name("mike");
    obj.set_id(1);
    //obj.set_email("mike@qq.com")

    *obj.mutable_email()="mike@qq.com";

    len = obj.ByteSize();
    //cout << "len: "<<  len << endl;
    //
    obj.SerializeToArray(arr,len);


}

void get_person()
{
    Person p;
    p.ParseFromArray(arr,len);
    cout << "name:"<<p.name()<<endl;
    cout << "id:"<<p.id()<<endl;
    cout << "email:"<<p.email()<<endl;


}

int main()
{
    GOOGLE_PROTOBUF_VERIFY_VERSION;
    set_person();
    get_person();
    google::protobuf::ShutdownProtobufLibrary();
    return 0;
}
